<include file="Common:header" />
<body>
<div class="crumb_warp">
    <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
    <i class="fa fa-home"></i> <a href="{:U(MODULE_NAME.'/Index/info')}">首页</a> &raquo; 单页管理
</div>
	<form>

        <div class="result_wrap">

            <!--快捷导航 开始-->
            <div class="result_title">
                <h3>快捷操作</h3>
            </div>
            <div class="result_content">
                <div class="short_wrap">
                    <a href="{:U(MODULE_NAME.'/Singlepage/add')}"><i class="fa fa-plus"></i>添加单页</a>
                    <a href="{:U(MODULE_NAME.'/Singlepage/index')}"><i class="fa fa-refresh"></i>刷新页面</a>
                </div>
            </div>
            <!--快捷导航 结束-->
        </div>


        <div class="result_wrap">
            <div class="result_content">
                <table class="list_tab">
			<tr>
				<th class="tc" width="3%">序号</th>
                <th class="tc" width="5%">排序</th>
				<th>单页名称</th>
				<th>操作</th>
			</tr>
			<foreach name="page" item="v">
			<tr>
				<td class="tc">{$v.id}</td>
                <td class="tc"><input type="text" size="20" name="ord[]" value="{$v.sort}" onchange="changeByorder(this,{$v['id']})"/></td>
				<td>{$v.name}</td>
				<td width="10%"><a href="{:U(MODULE_NAME.'/Singlepage/edit',array('id'=>$v['id']))}">修改</a>&nbsp;&nbsp;<a href="javascript:;" onclick="delSingle({$v['id']})">删除</a>
				</td>
			</tr>
			</foreach>
		</Table>

            </div>
        </div>
	</form>
</body>
</html>
<script type="text/javascript">
    //异步排序修改
    function changeByorder(obj,id){
        var sort = $(obj).val();
        $.post('{:U(MODULE_NAME."/Singlepage/change")}',{'sort':sort,'id':id},function(data){
            if(data.status==1){
                layer.alert(data.info, {icon: 6});
                $(".layui-layer-btn .layui-layer-btn0").click(function(){
                    location.href=location.href;
                })
            }else{
                layer.alert(data.info, {icon: 5});
            }
        });
    }


    //异步删除分类
    function delSingle(id){
        //layer询问框
        layer.confirm('您确定要删除吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post('{:U(MODULE_NAME."/Singlepage/delete")}',{'id':id},function(data){
                if(data.status==1){
                    layer.msg(data.info);
                    location.href=location.href;
                }else{
                    layer.msg(data.info);
                }
            });
        });
    }

</script>